
#include "WindowInterface.h"
#include <GL/gl.h>

// --------------------------------------------------------------------------------------
WindowInterface::WindowInterface(const WindowSettings& ws)
	: settings(ws), keyMap()
{
}
// --------------------------------------------------------------------------------------
WindowInterface::~WindowInterface(void)
{
	// fechar a janela
}
// --------------------------------------------------------------------------------------
bool WindowInterface::isKeyDown( WindowInterface::KeyCode key )
{
	if( keyMap.find( key ) == keyMap.end() )
		return false;

	return keyMap[key];
}
// --------------------------------------------------------------------------------------
void WindowInterface::resize( int width, int height)
{
	settings.width = width;
	settings.height = height;
	//
	glViewport(0,0,width, height);
	// NOTA: melhora o desempenho
	//glEnable(GL_SCISSOR_TEST);
	//glScissor( 0,0, width, height);


	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();    // rescala o Y
	float sy = (height) ? ((float)width/(float)height): 1.0f;
	glScalef( 1.0f, sy, 1.0f);
	glMatrixMode(GL_MODELVIEW);
}
// --------------------------------------------------------------------------------------

